﻿using System.Collections.Generic;

namespace studentSubsidy.Utils
{
    public class PageHelper
    {
        public static List<T> PageStart<T>(int currentPage, int pageSize, int countTotal, List<T> items)
        {
            List<T> pageReturn = new List<T>();
            if (pageSize * currentPage - 1 >= countTotal)
            {
                for (int i = pageSize * (currentPage - 1); i <= items.Count - 1; i++)
                {
                    pageReturn.Add(items[i]);
                }
            }
            else
            {
                for (int i = pageSize * (currentPage - 1); i <= pageSize * currentPage - 1; i++)
                {
                    pageReturn.Add(items[i]);
                }
            }

            return pageReturn;
        }
    }
}